#ifndef dq_Item_h
#define dq_Item_h

#include "Record.h"
#include "DeclareList.h"
#include <utility/String.h>
#include <vector>

namespace serika
{
	namespace db
	{
		class Item;
	}

	namespace dq
	{
		class Property;

		class Item
		{
			typedef Record<db::Item> DbItem;

			Item(db::Item* item, TransientState::Enum state);
		public:
			virtual ~Item();

			static Item* NewItem(int itemType, int buyPrice, int sellPrice,
				const ut::String& chinessName, const ut::String& japanessName);
			static Item* FromDb(db::Item* item);
			static Item* FromDb(db::Item* item, const Properties& properties);

			int GetId() const;
			int GetItemType() const;
			int GetBuyPrice() const;
			int GetSellPrice() const;
			const ut::String& GetChinessName() const;
			const ut::String& GetJapanessName() const;
			ut::String GetPropertyIds() const;
			const Properties& GetProperties() const;

			void SetItemType(int itemType);
			void SetBuyPrice(int buyPrice);
			void SetSellPrice(int sellPrice);
			void SetChinessName(const ut::String& name);
			void SetJapanessName(const ut::String& name);
			void AddProperty(Property* itemProperty);
			void AddProperty(const Properties& properties);
			void DelProprety(Property* itemProperty);

			void Save();
			void Delete();

		private:
			DbItem* mDbItem;
			Properties mProperties;

			void FormPropertiesString(ut::String& ids) const;
		};
	}
}

#endif
